$(function(){
    var id = $("#examplePicId_update").val();
    if(id){
        $.ajax({
            type : "post",
            url : "htmlWeb/getExampleDetail",
            data: {"id" : id},
            async: false,
            success : function(data){
                var str = "";
                data = trimEmpty(data);
                $("#picName").val(data.name);
                $("#picSort").val(data.status);
                $("#preview").attr("src","http://img.boyitongcheng.com/" + data.imgUrl);
            },
            error : function(data){
                console.log(data);
            }
        });
    }

    $(".save").click(function () {
        var options = {
            url: '/htmlWeb/submitExampleDetail',
            type: 'post',
            success: function (data) {
                $.ajaxSetup({cache: false});
                cancle();
            },
            error:function () {
                $.ajaxSetup({cache: false});
                tip("上传失败");
                cancle();
            }
        };
        $("#form").ajaxForm(options);
    });
});

function cancle(){
    var id = $("#exampleId_update").val();
    var jsPath = "../../by-webhtml/assets/js/system/system_picList.js";
    $(".mainDiv").load("/htmlWeb/systemPicListHtml", '', function () {
        $("#exampleId").val(id);
        $.getScript(jsPath);
    });
}